<?php
define('IN_KS', TRUE);
require dirname(__FILE__).'/inc/common.inc.php';
checkey(KS_KEY);


require KS_ROOT.'inc/user.class.php';
$user = new User();

if(!isset($file)) $file = 'welcome';
preg_match("/^[0-9A-Za-z_-]+$/", $file) or showmessage('Invalid Request.');
if(!isset($forward) && str_exists(HTTP_REFERER, '?')) $forward = HTTP_REFERER;

session_start();


if(get_cookie('usercode')){
    $_usercode = get_cookie('usercode');
    $u = $user->getbycode($_usercode);
    $_userid = $u[id];
}

if(get_cookie("login"))
{
    $username = get_cookie("username");
}
elseif($file != 'login')
{
    Header("Location: ?file=login&forward=".urlencode(URL));
}


if(!@include KS_ROOT.$file.'.php') showmessage("The file ./{$file}.php is not exists!");
?>